#include <stdio.h>
#include <stdarg.h>

/**
 * @brief
 * [Info][file name]:xxxxalex_bill
 *
 */

#define LOG_I(fmt, ...)                                        \
    do {                                                       \
        char output[128];                                      \
        snprintf(output, sizeof(output), "[Info]: %s\n", fmt); \
        printf(output, ##__VA_ARGS__);                         \
    } while (0)

#define LOG_W(fmt, ...) log_w(fmt, ##__VA_ARGS__)
#define LOG_W2(...)     log_w(__VA_ARGS__)

void log_w(char *fmt, ...) {
    va_list arg;
    va_start(arg, fmt);

    char fmt_out[128] = {0x00};
    int  n            = snprintf(fmt_out, sizeof(fmt_out), "%s", "[Warn]:");
    vsnprintf(fmt_out + n, sizeof(fmt_out) - n, fmt, arg);
    printf("%s\n", fmt_out);
    va_end(arg);
}

void fun01() {
    LOG_I("hello world");
    LOG_I("hello world: %s", "alex");

    LOG_W("hello world");
    LOG_W("hello world: %s", "alex");
    LOG_W2("hello world");
    LOG_W2("hello world: %s", "alex");
}

int main(int argc, char *argv[]) {
    fun01();
    return 0;
}